#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT(JSBSimCommander, 0.1.2, matthewzhenggong@gmail.com)
AC_CONFIG_SRCDIR([src/Commander.cpp])
AM_INIT_AUTOMAKE()
AC_CONFIG_SRCDIR([src/config.h.in])
AC_CONFIG_HEADER([src/config.h])
AC_CANONICAL_HOST

# Checks for programs.
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_MKDIR_P
AC_CANONICAL_HOST
AC_PROG_CXX
AC_CHECK_TOOL(RC, windres)
AC_LANG_CPLUSPLUS


ALL_LINGUAS="de fr it zh_CN"
AM_GNU_GETTEXT([external])
AC_DEFINE_UNQUOTED(LOCALEDIR, "${prefix}/${DATADIRNAME}/locale", [Name of gettext locale directory])


# Check for wx
AM_OPTIONS_WXCONFIG
AM_PATH_WXCONFIG(2.6.0, [wxWin=1], [wxWin=0], [xrc html adv core xml base], [])
     if test "$wxWin" != 1; then
        AC_MSG_ERROR([
                wxWidgets must be installed on your system
                but wx-config script couldn't be found.

                Please check that wx-config is in path, the directory
                where wxWidgets libraries are installed (returned by
                'wx-config --libs' command) is in LD_LIBRARY_PATH or
                equivalent variable and wxWidgets version is 2.6.0 or above.
        ])
     fi
AC_MSG_CHECKING([for WX_INCLUDES])
    if test "x$WX_INCLUDES" = x ; then
        WX_INCLUDES="`echo ${WX_CXXFLAGS} | awk '{print $1 \"  \" $2}'`"
    fi

    if test "x$WX_INCLUDES" = x ; then
      AC_MSG_RESULT([not found])
    else
      AC_MSG_RESULT([$WX_INCLUDES])
    fi
AC_SUBST(WX_INCLUDES)
AM_PATH_WXRC([HAVE_WXRC=1], [HAVE_WXRC=0])
     if test "x$HAVE_WXRC" != x1; then
         AC_MSG_NOTICE([
                The wxrc program was not installed or not found.
     
                Please check the wxWidgets installation.
         ])
     fi

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([float.h memory.h stddef.h stdlib.h string.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_STRUCT_TM

# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_STRTOD
AC_CHECK_FUNCS([floor memmove memset pow sqrt strdup strtol])

# Used for enabling the "-no-undefined" flag while generating DLLs
# Borrowed from the official gtk+-2 configure.in
AC_MSG_CHECKING([for some Win32 platform])
case "$host" in
  *-*-mingw*|*-*-cygwin*)
    platform_win32=yes
    declare COMMANDER_RES="commander.res"
    declare WIN32_LDADD="-lws2_32"
    ;;
  *)
    platform_win32=no
    declare COMMANDER_RES=""
    declare WIN32_LDADD=""
    ;;
esac
AC_MSG_RESULT([$platform_win32])
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
  
AC_SEARCH_LIBS(libiconv, iconv)
  
AC_SUBST(COMMANDER_RES)
AC_SUBST(WIN32_LDADD)

AC_OUTPUT(  po/Makefile.in\
    Makefile \
    src/Makefile \
    src/simgear/Makefile \
    src/simgear/props/Makefile \
    src/simgear/xml/Makefile \
    src/input_output/Makefile \
    src/math/Makefile \
    src/mattplot/Makefile \
    src/wx/Makefile \
    src/wx/plot/Makefile \
    src/wx/deprecated/Makefile \
    src/wx/ogl/Makefile \
    src/gui/Makefile \
    src/bitmaps/Makefile \
    src/rc/Makefile 
    )

